package com.kylin.upms.biz.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.kylin.upms.biz.entity.MenuRole;
import com.kylin.upms.biz.mapper.MenuRoleMapper;
import com.kylin.upms.biz.service.IMenuRoleService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Mht
 * @since 2019-04-11
 */
@Service
public class MenuRoleServiceImpl extends ServiceImpl<MenuRoleMapper, MenuRole> implements IMenuRoleService {


    @Autowired
    MenuRoleMapper menuRoleMapper;

    @Transactional
    @Override
    public void save(List<MenuRole> menuRoles) {

        Wrapper<MenuRole> wrapper = new EntityWrapper<>();
        wrapper.where("rid={0}",menuRoles.get(0).getRid());
        this.delete(wrapper);
        menuRoleMapper.save(menuRoles);
    }
}
